package com.galo.service.service;

import com.alibaba.fastjson.JSON;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

import java.util.LinkedHashMap;
import java.util.Map;

/**
 * 传感器接口
 * @Auther: lxlin
 * @Date: 2018/11/16 13:17
 * @Description:
 */
@Component
public class SensorService {

    @Autowired
    private MqttGateway gateway;

    /**
     * 通用传感器接口
     * 请求方式：GET
     * @param devsn 设备编号
     */
    @Async("taskExecutor")
    public void sensor(String devsn)
    {
        Map map = new LinkedHashMap();
        map.put("type","sensor");
        map.put("action","get");
        map.put("devsn",devsn);
        gateway.sendToMqtt("galo/device/sensor" ,1, JSON.toJSONString(map));
    }

}
